require "ftools";

class Dir

  def self.each_entry(dir, &block)
    dir = dir.gsub("\\", "/").sub(/\/$/, "");
    (entries(dir) - [".", ".."]).each do |entry|
      path = dir + "/" + entry;
      if File.directory?(path)
        each_entry(path, &block);
      else
        block.call(entry, dir);
      end
    end
  end
  
end

p(lambda{

site = "D:/Developer/Workspaces/Admin/Bermonruf PHP";
default = "#{site}/stylesheets/default.css";
old = "#{site}/stylesheets/old"

Dir.each_entry(site) do |file, dir|
  if file =~ /basics?\.css$/
    app_dir = dir.match(/Bermonruf PHP\/(.*)$/)[1].gsub("/", "-");
    Dir.chdir(old);
    Dir.mkdir(app_dir);
    file_path = "#{dir}/#{file}"
    File.copy(file_path, app_dir)
    Dir.chdir(dir);
    File.delete(file);
    File.copy(default, file);
  end
end
default

}.call)